package Project.QuickHit;

import Project.QuickHit.Game;

import java.util.Scanner;

public class Player {

    private int levelNo; //玩家当前级别号
    private int currScore; //玩家当前级别积分
    private long startTime; //当前级别开始时间
    private int elapsedTime; // 当前级别已用时间

    public Player() {
    }

    public Player(int levelNo, int currScore, long startTime, int elapsedTime) {
        this.levelNo = levelNo;
        this.currScore = currScore;
        this.startTime = startTime;
        this.elapsedTime = elapsedTime;
    }

    public int getLevelNo() {
        return levelNo;
    }

    public void setLevelNo(int levelNo) {
        this.levelNo = levelNo;
    }

    public int getCurrScore() {
        return currScore;
    }

    public void setCurrScore(int currScore) {
        this.currScore = currScore;
    }

    public long getStartTime() {
        return startTime;
    }

    public void setStartTime(long startTime) {
        this.startTime = startTime;
    }

    public int getElapsedTime() {
        return elapsedTime;
    }

    public void setElapsedTime(int elapsedTime) {
        this.elapsedTime = elapsedTime;
    }
    public void play(){
        Game game=new Game(this);
        Scanner input=new Scanner(System.in);
        this.setLevelNo(1);
        do{
            String out=game.printStr();
            System.out.println(out);
            long startTime = System.currentTimeMillis();
            String in=input.next();
            long endTime= System.currentTimeMillis();
            int TotalTime = (int) ((endTime - startTime)/1000);
            this.setElapsedTime(TotalTime);
            game.printResult(out,in);
            if (this.getCurrScore()>=50) {
                this.setLevelNo(this.getLevelNo()+1);
                this.setCurrScore(0);
                this.setElapsedTime(0);
            }
        }while (game.flag==true);
    }
}
